// 做题类型：全部、标签、章节、套题、知识点
export type PracticeType = "set" | "wrong" | "favorite";

// 做题模式：答题模式、查看模式
export type PracticeMode = "exam" | "view";

export type QuestionOptionNo = "A" | "B" | "C" | "D";
export type QuestionOptionState = "correct" | "wrong" | "empty" | "choosed";

export enum QuestionType {
  SINGLE = 1,
  MULTIPE = 2,
  JUDGE = 3,
}

export enum CarType {
  C1 = 1,
  D = 2,
  A2 = 3,
  A1 = 4,
  C6 = 5,
}

export enum Subject {
  ONE = 1,
  FOUR = 4,
}

export type QuestionState = {
  loadState: "silent" | "loading" | "success" | "error"; // 加载状态
  actionRecord: QuestionActionRecord | null; // 做题历史
  question: Question | null; // 题目
  isCollect: boolean; // 是否收藏
};

export type QuestionActionRecordWithId = QuestionActionRecord & {
  questionId: Question["id"];
};

export enum QuestionActionRecordSource {
  EXAM = 1,
  ITEM = 2,
}

export type QuestionActionRecord = {
  lastErrorAnswerRecord: boolean | null; // 上次的正确还是错误
  carType: CarType; // 车型;1.小车C1/C2/C3 2.摩托车D/E/F 3.货车/A2/B2 4.客车A1/A3/B1 5.轻型牵引挂车C6
  subject: Subject; // 科目;1.科目一 4.科目四
  actionCount: number; // 做题次数
  errorCount: number; // 错误次数
  updatedAt?: number | null; // 更新时间
};

export type QuestionOptionIndex = 1 | 2 | 3 | 4;

export type QuestionOption = {
  index: QuestionOptionIndex; // 选项序号
  answer: string; // 选项内容
};

export type Question = {
  id: string; // 题目id
  questionType: QuestionType; // 题目类型
  questionTitle: string; // 题目标题
  questionPic: string; // 题目图片
  questionOptionIndex: QuestionOptionIndex[]; // 题目答案
  questionAnswer: QuestionOption[]; // 题目选项
  remark: string; // 题目备注
  officialGuide: string; // 官方解释
  skillText: string; // 技巧解释(vip课程)
  skillImgs: string; //技巧图片(vip课程)
  chapterId: string; // 章节编号
  carType: CarType; // 车型;1.小车C1/C2/C3 2.摩托车D/E/F 3.货车/A2/B2 4.客车A1/A3/B1 5.轻型牵引挂车C6
  subject: Subject; // 科目;1.科目一 4.科目四
};

export type QuestionCollectReq = Pick<Question, "id" | "carType" | "subject">;

export type UpdateActionRecordParams = {
  questionId: Question["id"];
  isCorrect: boolean;
};

export type ToggleFavoriteQuestionParams = {
  questionId: Question["id"];
};

export type QuestionActionAttrs = {
  isCorrect: boolean;
};

export type PracticeStatus = "normal" | "time-end" | "abandon-overtime" | "abandon-flunk"; // ing:考试中 overtime:考试超时 flunk:考试不及格

export type QuestionChapter = {
  id: string;
  chapterName: string;
  chapterCode: number;
  carType: Question["carType"];
  subject: Question["subject"];
  questionCount: number;
};

export type QuestionChapterResp = {
  chapterId: QuestionChapter["id"];
  chapterName: QuestionChapter["chapterName"];
  errorQuestionCount?: number;
  collectQuestionCount?: number;
};

export type QuestionSet = {
  id: string;
  name: string;
  description: string;
  carType: CarType;
  subject: Subject;
};

export type MemberErrorQuestionRespVO = {
  chapterId: string;
  errorQuestionCount: string;
  chapterName: string;
};
export type MemberCollectQuestionRespVO = {
  chapterId: string;
  collectQuestionCount: string;
  chapterName: string;
};
